import React, { Component } from 'react'
import './index.css'

export default class Header extends Component {

    handleKeyUp = (e) => {
        if (e.keyCode === 13 && e.target.value !== '') {
            let obj = {
                id: new Date().getTime(),
                name: e.target.value,
                done: false
            }
            this.props.getValue(obj)
            e.target.value = ''
        }
    }

    render() {
        return (
            <div className="header">
                <input onKeyUp={this.handleKeyUp} type="text" />
            </div>
        )
    }
}